/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package load.education;

import core.InPort;
import core.OutPort;
import core.StdNode;
import javax.swing.JOptionPane;

/**
 *
 * @author Ben
 */
public class AskNumber extends StdNode{
    private InPort message = new InPort(String.class);

    private OutPort number = new OutPort(Integer.class)
    {
        @Override
        public Object getValueInternal() {
            String str = JOptionPane.showInputDialog((String)message.getValue());
            Integer result = null;
            try{
                result = Integer.parseInt(str);
            }catch(Exception ex){
                result = new Integer(0);
            }
            return result;
        }
    };

    public AskNumber() {
        this.autoPutPorts();
    }

}
